package org.zjx.action.login;

import org.zjx.action.Action;
import org.zjx.core.IWindow;
import org.zjx.util.ImageUtil;

import java.awt.*;
import java.awt.image.BufferedImage;


public class LoginHomeAction extends Action {
    public static final BufferedImage HOME_NEXT_IMAGE = ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAAHgAAAAnCAYAAADEvIzwAAARLElEQVR4Xu2bSXAVR5rH//gyWDNjFiOhfUPS04pA+4KE9l1CEqAFBBLdYrEl0xIYI4ndeEAsErIWEAixtd3NRE/bdER7oju6D46ZOTARjg4f5tCHOXDkMAcOfZjbzPdlZdbLl1VPeg/DTHSED7/IrKysqnz5yy8z6+kJEYXNiComSpgmROxoRjTlo3e0IIqILG9DdFkrooiCjm4cHD2K8X8YxfzSGeIs5u+fwdySBefn73GZxZxMRbnKL3vPizzzwEoXls9h4YHFvGThoS/z+vEj53kf1PXynr7nz0v0vL9j7T7L/FnGMXfnFG4tjOLG7EeYXjhBn3Xc+5wH2nX3J7Bw9yTVG8bk1GFMTv5EpHzM5fY1XO8JXbcsUz1P6ekrI+gbPYzcjk6sWbsWa9aswZp33sHa5DSElzX6BRFSbjSlkWUklYgubbYop/zOViF48PQQSTwrYLFK6JwtTwrWhHoF60LPifTeF5eJT630S+IXn4n8EqXMk68+9/I1p7NWSnz9+zvEosUfly3+8IBYxh///QuDL+388z99tSL/8qenrnzzr4/xzbdevv4dPf+fb+Orb+bx1W9n8avfTGPpySU8fnodT/6R2v6rqxa/nhQsfXnR4gmJXDpJA+Mj3Jo+IphdHBFlAhK+9HBc1BP8kq55JFM6XnxksXtPmVdwUrotM0JAQVrepAkuZakkWaQEC+UoZna2CLknPv2ZkHX38ThOj+9H3+EhdPZ2o7mz38tuLW/C5wKgtl0xoKUWBQ1HNY4EcKzQj/U6weNtj95WYhdzEDVtFq2dBH0eiwEX+tFCdVo6DqClvc8LH9uoewxQX3eh79gQxiZ6SfgYJj87iJ8cqBKSzQiOJGJLiZ2Ur2gCIktarAimiI2iiI0qJ8ECFtyK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Dui1JCMsrEpI3pmdhfVoaMksKcOUKRfGNfmTnZoobByJ0W/lRFFb9deLWdlXGaXCY/RIkLgNIRG9RHs6e7cS1qQFs2VFMM3AWzcA5CC8qRWRFNeLqmhBdU4e/p+UX6xITxTS99v0N2LQ9X6zHoTkF2Jy9HYnF+Tg21IypKZI82U/rcpaM5EY/cp2dY3fSa2Bep47Ne/+14RwIChfJEhW52XlZImLPnGjE4FAbQrfnIKywGBEUsVGVJLepDXENzYhv60RsQwsQW9+IkLBQITkkIoJGQi4iy3Yiopjm8aIiZO0oxNBwM65cHaBFvJ8Wc96AZYnFXSzyP/L2kRspnpanbgzg8uVeHD9OEotyxHobU0Vi65sQQ2ITd+1GAsnd0tlDdAMp+w9gc1Ex1pJgXo//LjqaRkQRoiuqaERUIbZ0BzJ3luL4R824cLGHRPcLLn/aK7h+bQDXrw9YqT/4/I8EBAucJqZk/sqkxdVJS+yF8SaMHG9CVuUORJeVI6a2DvEctU0t2NK+G4lEclcvkrpI8O4eILWvnw72YX1ykrUeb1yPdUlJFMElFOKNiK2rR0xpKTKry7Gnp05sx1n2yZ81Ci6casKFcx3iwZ9+0igQxz/yg7h8oVOsswz3LUdsd18tihprEF+Sj6iKSjEVJ7TSpretA0m7u0hoN5J7DyCFSO7po7QP/wuzfRMDQj15/AAAAABJRU5ErkJggg==");
    public static final Rectangle HOME_NEXT_BUTTON = ImageUtil.createRect(640, 527, 759, 565);


    public LoginHomeAction(IWindow targetWindow) {
        super(targetWindow, false);
    }

    @Override
    protected void doExecute() {
        targetWindow.execute(op->{
            op.click((int) HOME_NEXT_BUTTON.getCenterX(),(int) HOME_NEXT_BUTTON.getCenterY());
            op.delay(1000);
            return  null;
        });
    }

    public static boolean validate(IWindow window) {
        BufferedImage screen = window.getState().getGameState().getScreenshot();
        return ImageUtil.haveImage(screen,HOME_NEXT_BUTTON,HOME_NEXT_IMAGE);
    }
}
